package com.my.chapter15;

public class practice38 {
    public static void main(String[] args) {
        CoffeeDecorator cappuccino = new Foam(
                new SteamedMilk(new BasicCoffee("espresso")));
        System.out.println(
                "Capuccino is: " + cappuccino.getType());
        CoffeeDecorator chocolateCoffee = new WhippedCream(
                new Chocolate(new BasicCoffee("hot coffee")));
        System.out.println("Chocolate Coffee is: " +
                chocolateCoffee.getType());
    }
}

class BasicCoffee {
    private String type;
    public BasicCoffee() {}
    public BasicCoffee(String type) { setType(type); }
    public void setType(String type) { this.type = type; }
    public String getType() { return type; }
}

class CoffeeDecorator extends BasicCoffee {
    protected BasicCoffee basic;
    public CoffeeDecorator(BasicCoffee basic) {
        this.basic = basic;
    }
    public void setType(String type) { basic.setType(type); }
    public String getType() { return basic.getType(); }
}

class SteamedMilk extends CoffeeDecorator {
    public SteamedMilk(BasicCoffee basic) {
        super(basic);
        setType(getType() + " & steamed milk");
    }
}

class Foam extends CoffeeDecorator {
    public Foam(BasicCoffee basic) {
        super(basic);
        setType(getType() + " & foam");
    }
}

class Chocolate extends CoffeeDecorator {
    public Chocolate(BasicCoffee basic) {
        super(basic);
        setType(getType() + " & chocolate");
    }
}

class Caramel extends CoffeeDecorator {
    public Caramel(BasicCoffee basic) {
        super(basic);
        setType(getType() + " & caramel");
    }
}

class WhippedCream extends CoffeeDecorator {
    public WhippedCream(BasicCoffee basic) {
        super(basic);
        setType(getType() + " & whipped cream");
    }
}
